using Common.Framework.Core.Common;
using VehicleModule.Api.Model;
using VehicleModule.Api.Service;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
	
namespace VehicleModule.Api.Controllers.v1
{
    /// <summary>
    ///车辆表
    /// </summary>
    [ApiVersion("1")]
    public class VehiclesController : AuthorizeBaseController
    {
        private readonly IVehiclesService vehiclesService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="vehiclesService"></param>
        public VehiclesController(
            IVehiclesService vehiclesService
            )
        {
            this.vehiclesService = vehiclesService;
        }
	
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("Create")]
        public async Task<ServiceResult> Create([FromBody] VehiclesCreateRequest request) => await vehiclesService.CreateAsync(request); 
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete("Delete")]
        public async Task<ServiceResult> Delete([FromBody] IdRequest request) => await vehiclesService.DeleteAsync(request);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("Update")]
        public async Task<ServiceResult> Update([FromBody] VehiclesUpdateRequest request) => await vehiclesService.UpdateAsync(request); 
        /// <summary>
        /// 查询 单个记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet("Get")]
        public async Task<ServiceResult> Get([FromQuery] IdRequest request) => await vehiclesService.GetAsync(request);
        /// <summary>
        /// 查询 分页记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet("GetList")]
        public async Task<ServiceResult<VehiclesGetListResponse>> GetList([FromQuery] VehiclesGetListRequest request) => await vehiclesService.GetListAsync(request);
    }
}
